Skip to content

feat: Add TypeScript definitions #9693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 15, 2025
Merged

Conversation

dplewis
Copy link
Member

@dplewis dplewis commented Apr 2, 2025

Pull Request

Issue

Generated types currently break typescript projects

Closes: #9672

Approach

Ensure index.js, ParseServer.js and LiveQuery/ParseLiveQueryServer.js are typed.

Summary by CodeRabbit

  • New Features

    • Introduced comprehensive TypeScript type definitions for core classes, configuration options, and adapters to enhance type safety and developer experience.
    • Added type-checking tests to verify TypeScript typings for key modules.
  • Documentation

    • Updated contributing guide with instructions for running and developing TypeScript type tests.
  • Chores

    • Added scripts and configuration for TypeScript type testing and linting.
    • Updated CI workflow to run type tests automatically.
    • Excluded test and config files from npm package and linting processes.

Copy link

parse-github-assistant bot commented Apr 2, 2025

🚀 Thanks for opening this pull request!

@dplewis dplewis requested a review from a team April 2, 2025 19:21
@dplewis dplewis mentioned this pull request Apr 2, 2025
Copy link

codecov bot commented Apr 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.01%. Comparing base (39ef22d) to head (236b417).
Report is 11 commits behind head on alpha.

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha    #9693      +/-   ##
==========================================
- Coverage   93.16%   93.01%   -0.15%     
==========================================
  Files         187      187              
  Lines       15068    15081      +13     
  Branches        0      174     +174     
==========================================
- Hits        14038    14028      -10     
- Misses       1030     1041      +11     
- Partials        0       12      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yog27ray
Copy link
Contributor

yog27ray commented Apr 5, 2025

@dplewis use of any as a type should be avoided.

@dplewis
Copy link
Member Author

dplewis commented Apr 5, 2025

@yog27ray i know but this is a foundational PR. Feel free to change it after we merge

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the type files need to be manually generated calling npm run build:types and then be committed as part of a PR? Would it be better to generate the type files as part of the release workflow and commit them? Or build the types in the CI and make sure there's no difference to the committed type files, to ensure types are always committed correctly, like with the options definitions.

@mtrezza mtrezza changed the title feat: Add initial Typescript definitions feat: Add initial TypeScript definitions Apr 7, 2025
@mtrezza mtrezza changed the title feat: Add initial TypeScript definitions feat: Add TypeScript definitions Apr 7, 2025
@dplewis dplewis requested a review from mtrezza April 14, 2025 04:55
@mtrezza mtrezza merged commit e86718f into parse-community:alpha Apr 15, 2025
23 of 24 checks passed
parseplatformorg pushed a commit that referenced this pull request Apr 15, 2025
# [8.2.0-alpha.1](8.1.1-alpha.1...8.2.0-alpha.1) (2025-04-15)

### Features

* Add TypeScript definitions ([#9693](#9693)) ([e86718f](e86718f))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 8.2.0-alpha.1

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Apr 15, 2025
parseplatformorg pushed a commit that referenced this pull request May 1, 2025
# [8.2.0](8.1.0...8.2.0) (2025-05-01)

### Features

* Add TypeScript definitions ([#9693](#9693)) ([e86718f](e86718f))

### Performance Improvements

* Add details to error message in `Parse.Query.aggregate` ([#9689](#9689)) ([9de6999](9de6999))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 8.2.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label May 1, 2025
Copy link

coderabbitai bot commented May 1, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This change set introduces comprehensive TypeScript type declarations for the Parse Server project. It adds new .d.ts files for core modules, adapters, and configuration options, and establishes a type-testing workflow using ESLint and the expect-type plugin. The build and CI processes are updated to generate and test type declarations. Supporting configuration files for TypeScript and ESLint are added or updated to enable type-safe development and testing. Documentation is updated to guide contributors on maintaining and testing type definitions. No changes to runtime logic are made; all modifications focus on type safety and developer tooling.

Changes

File(s) Change Summary
src/LiveQuery/ParseLiveQueryServer.ts, src/ParseServer.ts Added and refined TypeScript type annotations for class properties and methods, improving type safety and clarity without altering runtime logic.
.github/workflows/ci.yml Added a CI step to run type tests (npm run test:types) after building type declarations.
.npmignore Excluded types/tests.ts and types/eslint.config.mjs from npm package.
CONTRIBUTING.md Added documentation on type tests, how to build and test type declarations, and updated the Table of Contents accordingly.
eslint.config.js Updated ESLint ignore patterns to exclude the types directory from linting.
package.json Added dev dependencies for eslint-plugin-expect-type and typescript-eslint, and new scripts for watching and testing types.
tsconfig.json, types/tsconfig.json Updated TypeScript configuration: set module/target options, added module path aliases, and included type test files.
types/@types/@parse/fs-files-adapter/index.d.ts, types/@types/deepcopy/index.d.ts Added temporary type declarations for third-party modules to support type checking.
types/LiveQuery/ParseLiveQueryServer.d.ts, types/ParseServer.d.ts, types/Options/index.d.ts Added comprehensive type declarations for core Parse Server modules and configuration options, specifying interfaces, classes, and method signatures.
types/eslint.config.mjs Introduced a dedicated ESLint config for type tests, integrating TypeScript ESLint and expect-type plugin.
types/index.d.ts Added main type entry point, declaring and exporting ParseServer, adapters, and utilities for type-safe imports.
types/tests.ts Added type tests using $ExpectType and $ExpectError comments to verify the correctness of type declarations for core modules and adapters.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant CI
    participant TypeScript Compiler
    participant ESLint

    Developer->>TypeScript Compiler: Run npm run build:types
    TypeScript Compiler-->>Developer: Generate .d.ts files

    Developer->>ESLint: Run npm run test:types
    ESLint-->>Developer: Lint types/tests.ts with expect-type plugin

    CI->>TypeScript Compiler: Build types (build:types)
    TypeScript Compiler-->>CI: .d.ts files generated

    CI->>ESLint: Test types (test:types)
    ESLint-->>CI: Type test results
Loading

Assessment against linked issues

Objective Addressed Explanation
Provide complete and correct TypeScript type declarations for Parse Server (#9672)
Ensure types/index.d.ts is populated and enables successful TypeScript compilation (#9672)
Add type tests to verify type correctness and prevent regressions (#9672)
Integrate type build and test steps into CI to catch type errors automatically (#9672)

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39ef22d and 236b417.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (17)
  • .github/workflows/ci.yml (1 hunks)
  • .npmignore (1 hunks)
  • CONTRIBUTING.md (2 hunks)
  • eslint.config.js (1 hunks)
  • package.json (4 hunks)
  • src/LiveQuery/ParseLiveQueryServer.ts (15 hunks)
  • src/ParseServer.ts (6 hunks)
  • tsconfig.json (1 hunks)
  • types/@types/@parse/fs-files-adapter/index.d.ts (1 hunks)
  • types/@types/deepcopy/index.d.ts (1 hunks)
  • types/LiveQuery/ParseLiveQueryServer.d.ts (1 hunks)
  • types/Options/index.d.ts (1 hunks)
  • types/ParseServer.d.ts (1 hunks)
  • types/eslint.config.mjs (1 hunks)
  • types/index.d.ts (1 hunks)
  • types/tests.ts (1 hunks)
  • types/tsconfig.json (1 hunks)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

types.ts is empty?
4 participants